# Contributor: Matthias Ahouansou <matthias@ahouansou.cz>
# Maintainer: Matthias Ahouansou <matthias@ahouansou.cz>
pkgname=lazymc
pkgver=0.2.11
pkgrel=0
pkgdesc="Put your Minecraft server to rest when idle"
url="https://github.com/timvisee/lazymc"
# loongarch64: libc crate
arch="all !loongarch64"
license="GPL-3.0-only"
makedepends="
	cargo
	cargo-auditable
"
install="$pkgname.pre-install"
subpackages="$pkgname-openrc"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/timvisee/lazymc/archive/refs/tags/v$pkgver.tar.gz
	lazymc.initd
	lazymc.confd
"
options="net !check" # no tests

prepare() {
	default_prepare
	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --release --frozen
}

package() {
	install -Dm 755 target/release/lazymc "$pkgdir"/usr/bin/lazymc

	install -Dm 755 "$srcdir"/lazymc.initd "$pkgdir"/etc/init.d/lazymc
	install -Dm 644 "$srcdir"/lazymc.confd "$pkgdir"/etc/conf.d/lazymc

	"$pkgdir"/usr/bin/lazymc config generate -c "$pkgdir"/etc/lazymc.toml
}

sha512sums="
64750b0bc5c4a4f08bf8aa19683b8415fdc62c0215208c4503e6d338c976decccf391aa0b8913676082d07a0e6ec7d45e05aef17e0765698679ca6eb2257a643  lazymc-0.2.11.tar.gz
29479bc55dbea006944b974ec507c907de43ab33dd7be27d41c42d157824ecc704b4ca4bb20a46dd889d92d5b715af4977ec9e92f2a2a8632ca3af942c873d7d  lazymc.initd
9eb8e36476c471c2ae42e5ca985746f0f020437cdc4e38c25eecde70605d3ee48db539370be991258c0b3e25a0946ce9245754c26d64d7ac2e1994ee573a5502  lazymc.confd
"
